package by.airlanterns.dao;

import by.airlanterns.dto.SiteAction;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Sergey
 * Date: 29.01.13
 * Time: 16:14
 * To change this template use File | Settings | File Templates.
 */
@Controller
public class ActionDaoImpl extends GenericDaoImpl<SiteAction, Integer> {

    @Override
    protected Class<SiteAction> getEntityClass() {
        return SiteAction.class;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public SiteAction getLastAction() {
        List<SiteAction> actions = getHibernateTemplate().find("from " + SiteAction.class.getName() + " where activated='yes' order by id_action desc");
        if (actions.size() != 0)
            return actions.get(0);
        else
            return new SiteAction();
    }
}
